import {
	request
} from '@/utils/request.js'
export default {
	state: {
		list: [] // 购物车数据
	},
	mutations: {
		getCartList(state, payload) {
			Object.keys(state).map((item, index) => {
				state[item] = payload[item]
			})
		},
		setList(state,{data,key}){
			state[key] = data
			uni.setStorageSync('cartList', state[key]);
		}
	},
	actions: {
		getCarList(state) {
			request({
				url: 'cart/synchro',
				method: 'POST',
				data: {
					cart: ''
				}
			}).then(res => {
				// state.list = res.data.data
				state.commit("setList",{key:'list',data:res.data.data})
			})
		}
	}
}
